#!/usr/bin/env bash

BUILD_PATH="/opt/we/we_vue"
WORK_PATH="/www/wwwroot/we/vue"
echo ==============================
echo   we 升级脚本启动
echo ==============================

cd ${BUILD_PATH}

echo 开始 pull 代码

git pull

echo 获取代码完成

echo 更新包

npm install

echo 更新完成

echo 开始编译代码

vue-cli-service build --mode production --dest dist --target app --dashboard

echo 编译完成

echo 备份原dist包
rm -rf ${WORK_PATH}/dist.bak
mv -rf ${WORK_PATH}/dist ${WORK_PATH}/dist.bak

echo 覆盖dist包
mv -rf ${BUILD_PATH}/dist ${WORK_PATH}/dist

echo 重启服务

systemctl restart nginx
systemctl status nginx
echo 完成
